package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.Exercises;

@Repository
public interface ExercisesDao extends JpaRepository<Exercises, Integer>, JpaSpecificationExecutor<Exercises> {

	@Query("from Exercises where videoClass_id = ?1")
	List<Exercises> find(String name);

	@Query("from Exercises where videoClass_id like ?1")
	List<Exercises> findLike(String name);

	@Query(value = "select * from Exercises limit ?, ?", nativeQuery = true)
	List<Exercises> findPage(Integer offset, Integer size);

	@Query(value = "select * from Exercises where videoClass_id = ? limit ?, ?", nativeQuery = true)
	List<Exercises> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from Exercises where videoClass_id like ? limit ?, ?", nativeQuery = true)
	List<Exercises> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from Exercises where videoClass_id = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from Exercises where videoClass_id like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from Exercises order by id asc")
	List<Exercises> findAllAsc();

	Integer countExercisesByDocumentation(Integer documentId);
}

